<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<!--
        This program is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation; either version 2 of the License, or
        (at your option) any later version.
        
        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.
        
        You should have received a copy of the GNU General Public License
        along with this program; if not, write to the Free Software
        Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
        MA 02110-1301, USA.
-->

<html>
	<head>
		<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
		<meta HTTP-EQUIV="Expires" CONTENT="-1">
		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
		<link type="text/css" href="../../css/jquery-ui/current/jquery-ui.css" rel="stylesheet" />
		<link type="text/css" href="../../css/iframe.css" rel="stylesheet" />
		<script type="text/javascript" src="../../js/jquery.js"></script>
		<script type="text/javascript" src="../../js/jquery-ui.js"></script>
		<script type="text/javascript" src="../../js/jquery.xslt.js"></script>
		<script type="text/javascript" src="../../js/jquery.form.js"></script>
		<script type="text/javascript" src="../../js/iframe.js"></script>
		<script type="text/javascript">
			function onChangeSPCode(){
				setTimeout(function () {
					$('#spquantity').focus();
				}, 100);
			};
		</script>
	</head>
	<body style="font-size:12px;">
		<div align="center" style="width:100%; height:100%">
			<form action="../../../../bin/kernel.py?func=addSPCode" method="post" id="spcodeform">
				<table>
					<tr>
						<td colspan="2">
							<div id="idcode">SP Consumption Code: </div>
							<input type="hidden" name="guid" id="guid" />
							<script language="javascript">
								$("#idcode").text($("#idcode").text() + GET()['id']);
								$("#guid").attr('value', GET()['id']);
							</script>
						</td>
					</tr>
					<tr>
						<td>SP code:</td>
						<td>
							<div id="spcode"></div>
						</td>
					</tr>
					<tr>
						<td>Quantity:</td>
						<td><input style="width:330px" type="text" value="0" name="quantity" id="spquantity" onfocus="this.select()" /></td>
					</tr>
					<tr>
						<td colspan="2" align="right">
							<button type="submit">add spare parts</button>
						</td>
					</tr>
				</table>
			</form>
			<div id="spcodetable"></div>
			<script language="javascript">
				function delSPCodeByID(id){
					$.ajax({
						type: "POST",
						url: "../../../../bin/kernel.py?func=delSPCodeByID",
						data: "id=" + id,
						success: function(msg){
							alert('deleted!');
							update('spcodetable', 'guid=' + GET()['id']);
						}
					})
				}
			
				$(function() {
					$("#spcodeform").ajaxForm(function() {
						alert("Added!!!");
						update('spcodetable', 'guid=' + GET()['id']);
					});	
							
					update('spcode');
					update('spcodetable', 'guid=' + GET()['id']);
				});
			</script>
		</div>
	</body>
</html>
